package temp;

import net.sourceforge.tess4j.Tesseract;
import net.sourceforge.tess4j.TesseractException;

import java.io.File;

/**
 * @package temp
 * @Class OCR
 * @Description TODO
 * @Author zhangxinhua
 * @Date 19-7-24 下午1:34
 */
public class OCR {
    public static void main(String[] args) {
        //验证码图片存储地址
        File imageFile = new File("/root/Pictures/Code.gif");
        if(!imageFile.exists()){
            System.out.println("图片不存在");
        }
        Tesseract tessreact = new Tesseract();
        tessreact.setDatapath("/root/Downloads/tesseract-3.01/tessdata/");

        String result;
        try {
            result = "测验结果：" + tessreact.doOCR(imageFile);
            System.out.println(result);
        } catch (TesseractException e) {
            e.printStackTrace();
        }
    }
}
